-- =============================================
-- Author:		Thijssen, Rob
-- Create date: 2007-05-08
-- Description:	Persist Resource
-- =============================================

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[PutResource]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
	DROP PROCEDURE PutResource
END
GO
CREATE PROCEDURE PutResource
	@ResourceName nvarchar(128),
	@ResourceValue nvarchar(1000),
	@ResourceObject nvarchar(255) = null,
	@CultureName nvarchar(50) = null
AS
BEGIN
	SET NOCOUNT ON;
	
	IF EXISTS (SELECT 1 FROM CultureResource WHERE ResourceName = @ResourceName AND ResourceObject = @ResourceObject AND CultureName = @CultureName) BEGIN
		UPDATE CultureResource SET ResourceValue = @ResourceValue WHERE ResourceName = @ResourceName AND ResourceObject = @ResourceObject AND CultureName = @CultureName
	END
	ELSE BEGIN
	
		INSERT INTO CultureResource (
			ResourceName,
			ResourceValue,
			ResourceObject,
			CultureName)
		VALUES (
			@ResourceName,
			@ResourceValue,
			@ResourceObject,
			@CultureName)

	END
	
END
GO
GRANT EXECUTE ON PutResource TO [AspNetResources]
GO